/*
 * Estadisticas.java
 *
 * Created on 7 de mayo de 2009, 12:05 AM
 */

package gui;

import conexion.RmiCliente;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.watermark.SubstanceImageWatermark;
import org.xml.sax.SAXException;
import persistencia.ConsultaEstadisticas;

/**
 *
 * @author  arquitectura
 */
public class Estadisticas extends javax.swing.JFrame {
    
    private String Usuario;
    private RmiCliente rc;
    private Estadisticas e;
    private String cadena;
    private Home gc;
    
    public JComboBox getJcOpcionEstadistica() {
        return jcOpcionEstadistica;
    }

    public void setJcOpcionEstadistica(JComboBox jcOpcionEstadistica) {
        this.jcOpcionEstadistica = jcOpcionEstadistica;
    }

    public JTextArea getJtEstadistica() {
        return jtEstadistica;
    }

    public void setJtEstadistica(JTextArea jtEstadistica) {
        this.jtEstadistica = jtEstadistica;
    }
    /** Creates new form Estadisticas */
    
     public Estadisticas(String usuario, RmiCliente rc, Home gc) {
        initComponents();
        
        this.setVisible(true);
        
        this.setSize(800, 625);
        this.setLocationRelativeTo(null);
        
        this.Usuario = usuario;
        this.rc = rc;
        this.e=this;
        this.gc = gc;
        cadena = new String();
       
        
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtEstadistica = new javax.swing.JTextArea();
        jcOpcionEstadistica = new javax.swing.JComboBox();
        jbMenuPrincipal = new javax.swing.JButton();
        jlIconEstadistica = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jtEstadistica.setColumns(20);
        jtEstadistica.setRows(5);
        jScrollPane1.setViewportView(jtEstadistica);

        jcOpcionEstadistica.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "Personales", "Globales" }));
        jcOpcionEstadistica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcOpcionEstadisticaActionPerformed(evt);
            }
        });

        jbMenuPrincipal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/volverahome.png"))); // NOI18N
        jbMenuPrincipal.setText("Menu Principal");
        jbMenuPrincipal.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jbMenuPrincipal.setBorderPainted(false);
        jbMenuPrincipal.setContentAreaFilled(false);
        jbMenuPrincipal.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_volverahome_roll.png"))); // NOI18N
        jbMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbMenuPrincipalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(119, 119, 119)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbMenuPrincipal)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcOpcionEstadistica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlIconEstadistica, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(189, 189, 189)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jcOpcionEstadistica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(168, 168, 168)
                        .addComponent(jlIconEstadistica, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbMenuPrincipal)
                .addContainerGap(106, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcOpcionEstadisticaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcOpcionEstadisticaActionPerformed
        // TODO add your handling code here:
      System.out.println("AAAAAAAAAAAAAAAAAAAAAA");
      cadena = this.rc.Consultas(Usuario, this.getJcOpcionEstadistica().getSelectedItem().toString());
      this.getJtEstadistica().setText(cadena);
      if(Usuario.equalsIgnoreCase("gonzalez.anamaria") && this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Personales") )
      {
        jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("Ana.jpg")));
        }
      else if(Usuario.equalsIgnoreCase("narvaez.ximena") && this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Personales"))
      {
        jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("ximena.jpg")));
        }
      else if(Usuario.equalsIgnoreCase("villalobos.victor") && this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Personales"))
      {
        jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("victor.jpg"))); 
        }
      else if(Usuario.equalsIgnoreCase("jaramillo.carlos") && this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Personales"))
      {
        //jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("http://72.29.81.246/~imindjav/Ana.jpg")));
        }
      else if(Usuario.equalsIgnoreCase("zorro.laura") && this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Personales"))
      {
        jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("laura.jpg")));
        }
      else if(this.getJcOpcionEstadistica().getSelectedItem().toString().equalsIgnoreCase("Globales"))
      {
        jlIconEstadistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("todos.jpg")));
        }
    }//GEN-LAST:event_jcOpcionEstadisticaActionPerformed

    private void jbMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbMenuPrincipalActionPerformed
        // TODO add your handling code here:
         this.dispose();
         JFrame.setDefaultLookAndFeelDecorated(true);

        SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/Home.jpg"));
        SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
        gc.setVisible(true);
    }//GEN-LAST:event_jbMenuPrincipalActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
         JFrame.setDefaultLookAndFeelDecorated(true);

        SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/Estadisticas.jpg"));
        SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
        /*java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Estadisticas().setVisible(true);
            }
        });*/
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbMenuPrincipal;
    private javax.swing.JComboBox jcOpcionEstadistica;
    private javax.swing.JLabel jlIconEstadistica;
    private javax.swing.JTextArea jtEstadistica;
    // End of variables declaration//GEN-END:variables
    
}
